package com.seele.tigerwallet.ui.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.seele.tigerwallet.R;
import com.seele.tigerwallet.model.MessageModel;
import com.seele.tigerwallet.model.TsModel;
import com.seele.tigerwallet.ui.manager.DaoManager;
import com.seele.tigerwallet.utils.Utils;

import java.util.List;

public class MessageAdapter  extends BaseQuickAdapter<MessageModel, BaseViewHolder> {

    private List<MessageModel> mMessageModelData;

    public MessageAdapter(int layoutResId) {
        super(layoutResId);
    }

    public void setNewData(List<MessageModel> data) {
        super.setNewData(data);
        this.mMessageModelData = data;
    }

    @Override
    protected void convert(BaseViewHolder helper, MessageModel item) {
        //跟数据库同步已读状态
       /*if (item.isEnd) {
            LinearLayout linearLayout = helper.getView(R.id.layout);
            LinearLayout linearLayoutEnd = helper.getView(R.id.layout_end);
            linearLayout.setVisibility(View.GONE);
            linearLayoutEnd.setVisibility(View.VISIBLE);
            return;
        }*/
        Log.i("API", "MessageAdapter:"+item.toString());
        helper.setText(R.id.tv_title, item.title);
        helper.setText(R.id.tv_content, item.content);
        String formatTime = Utils.formatTransferTime(item.confirmtime);
        helper.setText(R.id.tv_time, formatTime);

        if (item.status == 1) {
            helper.setTextColor(R.id.textview_title, Color.parseColor("#3F42466D"));
            helper.setTextColor(R.id.tv_title, Color.parseColor("#3F42466D"));
            helper.setTextColor(R.id.tv_detail, Color.parseColor("#3F42466D"));
            helper.setTextColor(R.id.tv_content, Color.parseColor("#3F42466D"));
            helper.setTextColor(R.id.tv_time, Color.parseColor("#3F42466D"));
        } else {
            helper.setTextColor(R.id.textview_title, Color.parseColor("#42466D"));
            helper.setTextColor(R.id.tv_title, Color.parseColor("#42466D"));
            helper.setTextColor(R.id.tv_detail, Color.parseColor("#42466D"));
            helper.setTextColor(R.id.tv_content, Color.parseColor("#42466D"));
            helper.setTextColor(R.id.tv_time, Color.parseColor("#42466D"));
        }

    }

}
